package com.abc.fast.server.user.service.impl;

import com.abc.fast.server.user.dao.UserRoleRelationDao;
import com.abc.fast.server.user.domain.entity.UserRoleRelation;
import com.abc.fast.server.user.service.IUserRoleRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserRoleRelationServiceImpl implements IUserRoleRelationService {

    @Autowired
    private UserRoleRelationDao userRoleRelationDao;


    @Override
    public void save(Long id, Long roleId) {
        UserRoleRelation userRoleRelation = buildUserRoleRelation(id, roleId);
        userRoleRelationDao.save(userRoleRelation);
    }

    private UserRoleRelation buildUserRoleRelation(Long id, Long roleId) {
        UserRoleRelation userRoleRelation = new UserRoleRelation();
        userRoleRelation.setRoleId(roleId);
        userRoleRelation.setUserId(id);
        return userRoleRelation;
    }
}
